<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<style type="text/css">
			.mui-bar{box-shadow: none;}
			.top-button{float: right;margin-top: 2.5%;margin-right: -3%;border: 0;background-color: #F7F7F7;color: #007AFF;}
			.mui-btn-primary:active{background-color: #F7F7F7 !important;border: 0!important;}
			.mui-content .mui-input-clear{margin-bottom: 0;border: 0;padding: 8% 5%;margin-top: 6%;}

		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav" id="header">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		    <h1 class="mui-title">个性签名</h1>
		    <button class="top-button mui-btn-primary" id="buttonm">完成</button>
		</header>
		
		
		<div class="mui-content">
            <textarea class="mui-input-clear" rows="3" placeholder="个性签名。。。" id="textarea" value="" onkeyup="ResizeTextarea()"></textarea> 
		</div>
		
		
		
		<script src="../../js/mui.min.js"></script>
		<script src="../../js/immersed.js" ></script>
		<script type="text/javascript">
			mui.init();
			
			//textarea自适应说说高度
		function ResizeTextarea() {
				// 最小高度  
				var minRows = 3;
				// 最大高度，超过则出现滚动条  
				var maxRows = 15;
				var t = document.getElementById('textarea');
				if(t.scrollTop == 0) t.scrollTop = 1;
				while(t.scrollTop == 0) {
					if(t.rows > minRows)
						t.rows--;
					else
						break;
					t.scrollTop = 1;
					if(t.rows < maxRows)
						t.style.overflowY = "hidden";
					if(t.scrollTop > 0) {
						t.rows++;
						break;
					}
				}
				while(t.scrollTop > 0) {
					if(t.rows < maxRows) {
						t.rows++;
						if(t.scrollTop == 0) t.scrollTop = 1;
					} else {
						t.style.overflowY = "auto";
						break;
					}
				}
			}
		
		
		
		
		window.onload = function(){
			mui.plusReady(function(){
				
				starbar();
				plus.navigator.setStatusBarStyle('dark');
				
				var Data = plus.webview.currentWebview();
				var qname = document.getElementById('textarea');
				 qname.value = Data.qname;
			    document.getElementById('buttonm').addEventListener('tap',function(){
					    mui.ajax({
							url: 'https://www.lunyuwang.com/mineController/updataAWord',
							data: {	
								lyuser_Card: plus.storage.getItem("card"),	
								lyuser_AWord: qname.value
							},
							async: true, //将false改为true
							crossDomain: true, //强制使用5+跨域
							dataType: 'json', //服务器返回json格式数据
							type: 'get', //HTTP请求类型
							timeout: 10000, //超时时间设置为10秒；
							//processData: false,
							headers: {
								'Content-Type': 'application/x-www-form-urlencoded'
							},
							success: function(data) {
								if(data.state == 1){
									var preView = plus.webview.currentWebview().opener(); //触发上一个页面刷新图片事件
			                         mui.fire(preView,'install',{ 
			                         	aword:  qname.value
			                        }); 
			                        mui.back();
		                       }
							},
							error: function(xhr, type, errorThrown) {
								//异常处理；
								mui.toast("修改失败了哦！")	
						    }
					    })
                })
			})
		}
		</script>
	</body>

</html>